<template>
  <div>
    <el-form
      ref="dicTypeForm"
      :rules="rules"
      :model="dicTypInfo"
      label-position="right"
      label-width="120px"
    >
      <el-row>
        <el-form-item label="🍁部门">
          <el-select v-model="dicTypInfo.depart_name" placeholder="部门">
            <el-option label="CEO" value="CEO"></el-option>
            <el-option label="财务部" value="财务部"></el-option>
            <el-option label="运营部" value="运营部"></el-option>
            <el-option label="人事部" value="人事部"></el-option>
            <el-option label="策划部" value="策划部"></el-option>
          </el-select>
        </el-form-item>
        <el-form-item label="🍁职位">
          <el-select v-model="dicTypInfo.zhiwei_name" placeholder="职位">
            <el-option label="董事长" value="董事长"></el-option>
            <el-option label="财务部部长" value="财务部部长"></el-option>
            <el-option label="运营部长" value="运营部长"></el-option>
            <el-option label="人事部长" value="人事部长"></el-option>
            <el-option label="策划部长" value="策划部长"></el-option>
          </el-select>
        </el-form-item>
      </el-row>
      <el-row>
        <el-form-item label="🍁员工姓名">
          <el-select v-model="dicTypInfo.yg_name" placeholder="员工姓名">
            <el-option label="张晓刚" value="张晓刚"></el-option>
            <el-option label="李四" value="李四"></el-option>
            <el-option label="王五" value="王五"></el-option>
            <el-option label="赵六" value="赵六"></el-option>
            <el-option label="周七" value="周七"></el-option>
          </el-select>
        </el-form-item>
        <el-col :span="10">
          <el-form-item label="🍁上级负责人">
            <el-select v-model="dicTypInfo.shangjipeo" placeholder="上级负责人">
              <el-option label="张晓刚" value="张晓刚"></el-option>
            </el-select>
          </el-form-item>
        </el-col>
      </el-row>
      <el-row>
        <el-col :span="6">
          <el-form-item label="🍁入职日期">
            <el-date-picker
              type="date"
              placeholder="选择日期"
              v-model="dicTypInfo.ruzhitime"
              style="width: 100%"
            ></el-date-picker>
          </el-form-item>
        </el-col>
      </el-row>
      <el-row>
        <el-col :span="6">
          <el-form-item label="🍁最后工作日">
            <el-date-picker
              type="date"
              placeholder="选择日期"
              v-model="dicTypInfo.latetime"
              style="width: 100%"
            ></el-date-picker>
          </el-form-item>
        </el-col>
      </el-row>
      <el-row>
        <el-col :span="10">
          <el-form-item label="🍁离职原因">
            <el-input
              type="textarea"
              v-model="dicTypInfo.lizhiyuanyin"
            ></el-input>
          </el-form-item>
        </el-col>
      </el-row>
    </el-form>
    <div slot="footer" class="dialog-footer">
      <!-- dialogStatus === '1' 是添加 就执行添加的方法  是修改  就执行修改的方法-->
      <el-button type="primary" @click="addDictType()"> 保存 </el-button>
      <el-button> 取消 </el-button>
    </div>
  </div>
</template>

  <script>
import { dttCreated } from "@/api/system_base/Hired_handle";

export default {
  data() {
    return {
      dialogStatus: "1", // 等于1 表示是添加操作   不等于1 表示修改操作
      dicTypInfo: {},
    };
  },
  created() {
    this.resetDicinfo();
  },
  methods: {
    addDictType() {
      if (this.dicTypInfo.depart_name == "") {
        this.$message("部门名称不能为空");
        return;
      }
      if (this.dicTypInfo.zhiwei_name == "") {
        this.$message("职位名称不能为空");
        return;
      }
      if (this.dicTypInfo.yg_name == "") {
        this.$message("员工姓名不能为空");
        return;
      }
      if (this.dicTypInfo.shangjipeo == "") {
        this.$message("上级负责人不能为空");
        return;
      }
      if (this.dicTypInfo.ruzhitime == "") {
        this.$message("入职日期不能为空");
        return;
      }
      if (this.dicTypInfo.latetime == "") {
        this.$message("最后工作日不能为空");
        return;
      }
      if (this.dicTypInfo.lizhiyuanyin == "") {
        this.$message("离职原因不能为空");
        return;
      }
      //添加方法
      this.$refs["dicTypeForm"].validate((valid) => {
        if (valid) {
          dttCreated(this.dicTypInfo).then((response) => {
            this.$router.push("/lizhi");
            this.$notify({
              title: "添加成功",
              message: "添加员工信息成功",
              type: "success",
              duration: 2000,
            });
          });
        }
      });
    },
    resetDicinfo() {
      // 初始化用户对象
      this.dicTypInfo = {
        depart_name: "",
        zhiwei_name: "",
        yg_name: "",
        shangjipeo: "",
        ruzhitime: "",
        latetime: "",
        lizhiyuanyin: "",
      };
    },
  },
};
</script>

<style >
.search_input {
  width: 200px;
}
</style>